package aop_demo;

import dynamic_demo.Hello;
import dynamic_demo.HelloImpl;
import org.springframework.aop.framework.ProxyFactory;

/**
 * @Author: Crystal
 * @Date: 2018/11/29 10:25
 **/
public class Client {

    public static void main(String[] args) {
        //创建代理工厂
        ProxyFactory proxyFactory = new ProxyFactory();
        //射入目标对象
        proxyFactory.setTarget(new HelloImpl());
        //添加前置增强
//        proxyFactory.addAdvice(new GreetingBeforeAdvice());
        //添加后置增强
//        proxyFactory.addAdvice(new GreetingAfterAdvice());
        //一个接口同时添加前置、后置增强
//        proxyFactory.addAdvice(new GreetingBeforeAndAfterAdvice());

        //环绕增强
        proxyFactory.addAdvice(new GreetingAroundAdvice());

        Hello hello = (Hello) proxyFactory.getProxy();

        hello.say("Aop Cyy");
    }

}
